<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<view>
			<!-- 使用getData方法 -->
			<button @click="getData">获取数据</button>
		</view>
		<view>
			<!-- 使用getData2方法 -->
			<button @click="getData2">获取数据-异步方法</button>
		</view>
		<view>
			<!-- 使用getData2方法 -->
			<button @click="getData3">测试拦截器</button>
		</view>
		<view class="container">
			<text class="container">容器属性:</text>
			<view class="text-area">
				<text class="item" @click="flexDirection()">flex-direction 属性</text>
			</view>
			<view class="text-area">
				<text class="item">flex-wrap 属性</text>
			</view>
			<view class="text-area">
				<text class="item">justify-content 属性</text>
			</view>
			<view class="text-area">
				<text class="item">align-items 属性</text>
			</view>
			<view class="text-area">
				<text class="item">align-content 属性</text>
			</view>
		</view>
		<view class="container">
			<text class="container">项目属性:</text>
			<view class="text-area">
				<text class="item">order 属性</text>
			</view>
			<view class="text-area">
				<text class="item">flex-shrink 属性</text>
			</view>
			<view class="text-area">
				<text class="item">flex-grow 属性</text>
			</view>
			<view class="text-area">
				<text class="item">flex-basis 属性</text>
			</view>
			<view class="text-area">
				<text class="item">flex 属性</text>
			</view>
			<view class="text-area">
				<text class="item">align-self 属性</text>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '@/utils/request.js'
	import {getUserInfo} from '@/api/user.js' // 记得加{}
	import axios2 from "@/utils/request2.js" // 与该文件输出的instance可以不同 axios2是个别名
	export default {
		data() {
			return {
				// title: 'Hello'
				title: 'Flex布局'
			}
		},
		onLoad() {

		},
		methods: {
			flexDirection() {
				uni.navigateTo({
					url: "/pages/flex-direction/flex-direction"
				})
			},
			getData() {
				getUserInfo(3)
					.then(res=>{
						console.log(33333)
						console.log(res)
						if(res.code == "200") {
							console.log(res.data.email)
						}
					})
					.catch(error=>{
						console.error(error)
					})				
			},
			async getData2() {
				await getUserInfo(1)
					.then(res=>{
						console.log(4444)
						console.log(res)
						if(res.code == "200") {
							console.log(res.data.email)
						}
					})
					.catch(error=>{
						console.error(error)
					})				
			},
			getData3() {
				axios2.get("/user/detail/1") // 不写全路径，则读baseURL
					.then(res=>{
						console.log(555)
						console.log(res)
						if(res.code == "200") {
							console.log(res.data.email)
						}
					})
					.catch(error=>{
						console.error(error)
					})				
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	.container {
		font-size: 32rpx;
		color: #8f8f94;
		margin-top: 30rpx;
	}
	.item {
		font-size: 24rpx;
		color: #8f8f94;
		line-height: 50rpx;
	}
</style>
